Task properties example: Remove holidays and weekends from task assignments

1.  From BOD, select TaskItem business object.

Note: You need Process Manager or Campaign Manager in your license key to see the TaskItem business object.

2.  Double-click the TaskItem business object to open the TaskItem in edit mode.

3.  Click the Properties tab.

4.  Select DueDate property by clicking on that row.

5.  Click the Constraints tab.

Note: This is the Property constraint tab below the property list, not the Constraints tab at the top for the object constraints.

6.  Add a new constraint named NoHolidaysOrWeekends.

7.  Select Active and choose error level from the Severity drop-down list.

8.  Enter the following instruction in the section for code:

 

DateTime proposedDate = (DateTime)proposedValue;

 

if (proposedDate.DayOfWeek == System.DayOfWeek.Saturday ||

    proposedDate.DayOfWeek == System.DayOfWeek.Sunday)

{

    constraintPassed = false;

}

else if (proposedDate.Month == 12 && proposedDate.Day == 25)

{ //Christmas

    constraintPassed = false;

}

else if (proposedDate.Month == 1 && proposedDate.Day == 1)

{ //New Year's

    constraintPassed = false;

}

// Add other holidays here

else

{

    constraintPassed = true;

}

9.  Click Save.

10. Click Publish.

11. Test to be sure you cannot use holidays or weekends as valid due dates for task items in System Setup > Task Viewer when editing or adding tasks. After clicking Save, a message appears and you will be able to enter another date that is not a holiday or weekend.